package com.jingdong.api.model;

/**
 * 商户信息模型
 *
 * @author 林生
 * @version 1.0.0
 */
public class MerchantInfo {
    
    /**
     * 商户名称
     */
    private String merchantName;
    
    /**
     * 商户电话
     */
    private String merchantPhone;
    
    /**
     * 商户地址
     */
    private String merchantAddress;
    
    /**
     * 营业执照
     */
    private String businessLicense;
    
    /**
     * 联系人
     */
    private String contactPerson;
    
    /**
     * 联系电话
     */
    private String contactPhone;
    
    /**
     * 商户类型
     */
    private String merchantType;
    
    /**
     * 构造函数
     */
    public MerchantInfo() {
        this.merchantType = "1";
    }
    
    /**
     * Builder模式构建器
     */
    public static class Builder {
        private MerchantInfo merchantInfo = new MerchantInfo();
        
        public Builder merchantName(String merchantName) {
            merchantInfo.merchantName = merchantName;
            return this;
        }
        
        public Builder merchantPhone(String merchantPhone) {
            merchantInfo.merchantPhone = merchantPhone;
            return this;
        }
        
        public Builder merchantAddress(String merchantAddress) {
            merchantInfo.merchantAddress = merchantAddress;
            return this;
        }
        
        public Builder businessLicense(String businessLicense) {
            merchantInfo.businessLicense = businessLicense;
            return this;
        }
        
        public Builder contactPerson(String contactPerson) {
            merchantInfo.contactPerson = contactPerson;
            return this;
        }
        
        public Builder contactPhone(String contactPhone) {
            merchantInfo.contactPhone = contactPhone;
            return this;
        }
        
        public Builder merchantType(String merchantType) {
            merchantInfo.merchantType = merchantType;
            return this;
        }
        
        public MerchantInfo build() {
            merchantInfo.validate();
            return merchantInfo;
        }
    }
    
    public static Builder builder() {
        return new Builder();
    }
    
    /**
     * 验证必填字段
     * 
     * @throws IllegalArgumentException 验证失败时抛出
     */
    public void validate() {
        if (merchantName == null || merchantName.trim().isEmpty()) {
            throw new IllegalArgumentException("商户名称 不能为空");
        }
        
        if (merchantPhone == null || merchantPhone.trim().isEmpty()) {
            throw new IllegalArgumentException("商户电话 不能为空");
        }
        
        if (merchantAddress == null || merchantAddress.trim().isEmpty()) {
            throw new IllegalArgumentException("商户地址 不能为空");
        }
        
        if (businessLicense == null || businessLicense.trim().isEmpty()) {
            throw new IllegalArgumentException("营业执照 不能为空");
        }
        
        if (contactPerson == null || contactPerson.trim().isEmpty()) {
            throw new IllegalArgumentException("联系人 不能为空");
        }
        
        if (contactPhone == null || contactPhone.trim().isEmpty()) {
            throw new IllegalArgumentException("联系电话 不能为空");
        }
    }
    
    // Getters and Setters
    public String getMerchantName() {
        return merchantName;
    }
    
    public void setMerchantName(String merchantName) {
        this.merchantName = merchantName;
    }
    
    public String getMerchantPhone() {
        return merchantPhone;
    }
    
    public void setMerchantPhone(String merchantPhone) {
        this.merchantPhone = merchantPhone;
    }
    
    public String getMerchantAddress() {
        return merchantAddress;
    }
    
    public void setMerchantAddress(String merchantAddress) {
        this.merchantAddress = merchantAddress;
    }
    
    public String getBusinessLicense() {
        return businessLicense;
    }
    
    public void setBusinessLicense(String businessLicense) {
        this.businessLicense = businessLicense;
    }
    
    public String getContactPerson() {
        return contactPerson;
    }
    
    public void setContactPerson(String contactPerson) {
        this.contactPerson = contactPerson;
    }
    
    public String getContactPhone() {
        return contactPhone;
    }
    
    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }
    
    public String getMerchantType() {
        return merchantType;
    }
    
    public void setMerchantType(String merchantType) {
        this.merchantType = merchantType;
    }
}
